﻿Imports cPOS.DAL
Public Class MainForm
    Dim od As New DataHandler

    Private Sub txtProduct_TextChanged(sender As Object, e As EventArgs) Handles txtProduct.TextChanged
        Dim productId = txtProduct.Text.Trim
        Dim item As Product = od.SearchProductId(productId)

        If Not IsNothing(item) Then
            txtDesc.Text = item.description
            txtQty.Text = CStr(item.unit)
            TxtPrice.Text = CInt(txtQty.Text) * item.srpprice
        End If
    End Sub

    Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
        grdItems.Rows.Add(New String() {txtProduct.Text, txtDesc.Text, txtQty.Text, TxtPrice.Text})
        txtProduct.Text = Nothing

        txtProduct.Focus()
    End Sub

    Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim grditemswidth As Integer = grdItems.Width
        grdItems.Columns(0).Width = grditemswidth * 0.2
        grdItems.Columns(1).Width = grditemswidth * 0.4
    End Sub
End Class
